﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ARA.Domain.Datas
{
    public class JoinSegment
    {
        public DateTime LoginDate { get; set; }
        public DateTime LogoutDate { get; set; }

        /// <summary>
        /// 秒
        /// </summary>
        public int Duration { get; private set; }
        public string DurationText { get; private set; }

        public string Computer { get; set; }
        public string IP { get; set; }

        public JoinSegment(string computer, string ip, DateTime loginDate, DateTime logoutDate)
        {
            Computer = computer;
            IP = ip;
            LoginDate = loginDate;
            LogoutDate = logoutDate;

            Duration = (int)((LogoutDate - LoginDate).TotalSeconds);

            int minute = Duration / 60;
            int hour = minute / 60;
            int day = hour / 24;
            hour = hour % 24;
            minute = minute % 60;
            int second = Duration % 60;

            DurationText = String.Format("{0:d2}天{1:d2}时{2:d2}分{3:d2}秒", day, hour, minute, second);
        }
    }
}
